home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / MetalIconFactory.java < prev    next >
Text File  |  1998-06-30  |  51KB  |  1,633 lines

  1. /*
  2.  * @(#)MetalIconFactory.java    1.27 98/03/11
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.metal;
  22.  
  23. import com.sun.java.swing.*;
  24. import com.sun.java.swing.plaf.UIResource;
  25. import java.awt.*;
  26. import java.io.Serializable;
  27.  
  28. /**
  29.  * Factory object that can vend Icons appropriate for Metal.
  30.  * These are used extensively in Metal via the defaults mechanism.
  31.  * While other Look and Feels use GIFs for some of these, doing this
  32.  * work in code facilitates things when switching to other Themes.
  33.  * <p>
  34.  * Warning: serialized objects of this class will not be compatible with
  35.  * future swing releases.  The current serialization support is appropriate
  36.  * for short term storage or RMI between Swing1.0 applications.  It will
  37.  * not be possible to load serialized Swing1.0 objects with future releases
  38.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  39.  * baseline for the serialized form of Swing objects.
  40.  *
  41.  * @version 1.27 03/11/98
  42.  * @author Michael C. Albers
  43.  */
  44. public class MetalIconFactory implements Serializable {
  45.  
  46.     // List of code-drawn Icons
  47.     private static Icon fileChooserDetailViewIcon;
  48.     private static Icon fileChooserHomeFolderIcon;
  49.     private static Icon fileChooserListViewIcon;
  50.     private static Icon fileChooserNewFolderIcon;
  51.     private static Icon fileChooserUpFolderIcon;
  52.     private static Icon internalFrameAltMaximizeIcon;
  53.     private static Icon internalFrameCloseIcon;
  54.     private static Icon internalFrameDefaultMenuIcon;
  55.     private static Icon internalFrameMaximizeIcon;
  56.     private static Icon internalFrameMinimizeIcon;
  57.     private static Icon radioButtonIcon; 
  58.     private static Icon treeComputerIcon;
  59.     private static Icon treeFloppyDriveIcon;
  60.     private static Icon treeFolderIcon;
  61.     private static Icon treeHardDriveIcon;
  62.     private static Icon treeLeafIcon;
  63.     private static Icon treeDarkControlIcon;
  64.     private static Icon treeLightControlIcon;
  65.  
  66.     private static Icon menuArrowIcon;
  67.     private static Icon menuItemCheckIcon;
  68.     private static Icon menuItemArrowIcon;
  69.     private static Icon checkBoxMenuItemIcon;
  70.     private static Icon radioButtonMenuItemIcon;
  71.  
  72.  
  73.     // Constants
  74.     public static final boolean DARK = false;
  75.     public static final boolean LIGHT = true;
  76.  
  77.     // Accessor functions for Icons. Does the caching work.
  78.     public static Icon getFileChooserDetailViewIcon() {
  79.     if (fileChooserDetailViewIcon == null) {
  80.         fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
  81.     }
  82.     return fileChooserDetailViewIcon;
  83.     }
  84.  
  85.     public static Icon getFileChooserHomeFolderIcon() {
  86.     if (fileChooserHomeFolderIcon == null) {
  87.         fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
  88.     }
  89.     return fileChooserHomeFolderIcon;
  90.     }
  91.  
  92.     public static Icon getFileChooserListViewIcon() {
  93.     if (fileChooserListViewIcon == null) {
  94.         fileChooserListViewIcon = new FileChooserListViewIcon();
  95.     }
  96.     return fileChooserListViewIcon;
  97.     }
  98.  
  99.     public static Icon getFileChooserNewFolderIcon() {
  100.     if (fileChooserNewFolderIcon == null) {
  101.         fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
  102.     }
  103.     return fileChooserNewFolderIcon;
  104.     }
  105.  
  106.     public static Icon getFileChooserUpFolderIcon() {
  107.     if (fileChooserUpFolderIcon == null) {
  108.         fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
  109.     }
  110.     return fileChooserUpFolderIcon;
  111.     }
  112.  
  113.     public static Icon getInternalFrameAltMaximizeIcon(int size) {
  114.     return new InternalFrameAltMaximizeIcon(size);
  115.     }
  116.  
  117.     public static Icon getInternalFrameCloseIcon(int size) {
  118.     return new InternalFrameCloseIcon(size);
  119.     }
  120.  
  121.     public static Icon getInternalFrameDefaultMenuIcon() {
  122.     if (internalFrameDefaultMenuIcon == null) {
  123.         internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
  124.     }
  125.     return internalFrameDefaultMenuIcon;
  126.     }
  127.  
  128.     public static Icon getInternalFrameMaximizeIcon(int size) {
  129.     return new InternalFrameMaximizeIcon(size);
  130.     }
  131.  
  132.     public static Icon getInternalFrameMinimizeIcon(int size) {
  133.     return new InternalFrameMinimizeIcon(size);
  134.     }
  135.  
  136.     public static Icon getRadioButtonIcon() {
  137.     if (radioButtonIcon == null) {
  138.         radioButtonIcon = new RadioButtonIcon();
  139.     }
  140.     return radioButtonIcon;
  141.     }
  142.  
  143.     public static Icon getTreeComputerIcon() {
  144.         if ( treeComputerIcon == null ) {
  145.         treeComputerIcon = new TreeComputerIcon();
  146.     }
  147.     return treeComputerIcon;
  148.     }
  149.  
  150.     public static Icon getTreeFloppyDriveIcon() {
  151.         if ( treeFloppyDriveIcon == null ) {
  152.         treeFloppyDriveIcon = new TreeFloppyDriveIcon();
  153.     }
  154.     return treeFloppyDriveIcon;
  155.     }
  156.  
  157.     public static Icon getTreeFolderIcon() {
  158.         if ( treeFolderIcon == null ) {
  159.         treeFolderIcon = new TreeFolderIcon();
  160.     }
  161.     return treeFolderIcon;
  162.     }
  163.  
  164.     public static Icon getTreeHardDriveIcon() {
  165.         if ( treeHardDriveIcon == null ) {
  166.         treeHardDriveIcon = new TreeHardDriveIcon();
  167.     }
  168.     return treeHardDriveIcon;
  169.     }
  170.  
  171.     public static Icon getTreeLeafIcon() {
  172.         if ( treeLeafIcon == null ) {
  173.         treeLeafIcon = new TreeLeafIcon();
  174.     }
  175.     return treeLeafIcon;
  176.     }
  177.  
  178.     public static Icon getTreeControlIcon( boolean isLight ) {
  179.         if ( isLight ) {
  180.         if ( treeLightControlIcon == null ) {
  181.             treeLightControlIcon = new TreeControlIcon( LIGHT );
  182.         }
  183.         return treeLightControlIcon;
  184.     }
  185.     else {
  186.         if ( treeDarkControlIcon == null ) {
  187.             treeDarkControlIcon = new TreeControlIcon( DARK );
  188.         }
  189.         return treeDarkControlIcon;
  190.     }
  191.     }
  192.  
  193.     public static Icon getMenuArrowIcon() {
  194.     if (menuArrowIcon == null) {
  195.         menuArrowIcon = new MenuArrowIcon();
  196.     }
  197.     return menuArrowIcon;
  198.     }
  199.  
  200.     public static Icon getMenuItemCheckIcon() {
  201.     if (menuItemCheckIcon == null) {
  202.         menuItemCheckIcon = new MenuItemCheckIcon();
  203.     }
  204.     return menuItemCheckIcon;
  205.     }
  206.  
  207.     public static Icon getMenuItemArrowIcon() {
  208.     if (menuItemArrowIcon == null) {
  209.         menuItemArrowIcon = new MenuItemArrowIcon();
  210.     }
  211.     return menuItemArrowIcon;
  212.     }
  213.  
  214.     public static Icon getCheckBoxMenuItemIcon() {
  215.     if (checkBoxMenuItemIcon == null) {
  216.         checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
  217.     }
  218.     return checkBoxMenuItemIcon;
  219.     }
  220.  
  221.     public static Icon getRadioButtonMenuItemIcon() {
  222.     if (radioButtonMenuItemIcon == null) {
  223.         radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
  224.     }
  225.     return radioButtonMenuItemIcon;
  226.     }
  227.  
  228.     public static Icon getHorizontalSliderThumbIcon() {
  229.       // don't cache these, bumps don't get updated otherwise
  230.     return new HorizontalSliderThumbIcon();
  231.     }
  232.  
  233.     public static Icon getVerticalSliderThumbIcon() {
  234.       // don't cache these, bumps don't get updated otherwise
  235.     return new VerticalSliderThumbIcon();
  236.     }
  237.  
  238.     // Internal Frame Close code
  239.     private static class InternalFrameCloseIcon extends InternalFrameMaximizeIcon {
  240.     Color slashColor;
  241.  
  242.         public InternalFrameCloseIcon(int size) { super(size); };
  243.  
  244.         public void paintIcon(Component c, Graphics g, int x, int y) {
  245.         super.paintIcon(c,g,x,y);
  246.  
  247.         slashColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  248.  
  249.         if (parentButton.getClientProperty("paintActive")  != Boolean.TRUE) {
  250.         slashColor = MetalLookAndFeel.getControlDarkShadow();
  251.         }
  252.         else if (buttonModel.isPressed() && buttonModel.isArmed()) {
  253.         slashColor = MetalLookAndFeel.getPrimaryControlInfo();
  254.         }
  255.  
  256.         g.translate(x, y);
  257.  
  258.         // draw slash (rectangles from bottom to top)
  259.         g.setColor(slashColor);
  260.         for (int i=2 ; iconSize >= i+4 ; i++) {
  261.         g.fillRect(i, iconSize-i-2, 2,2);
  262.         }
  263.  
  264.         g.translate(-x, -y);
  265.     }
  266.     
  267.     public int getIconWidth() {
  268.         return iconSize;
  269.     }
  270.  
  271.     public int getIconHeight() {
  272.         return iconSize;
  273.     }
  274.     }  // End class InternalFrameCloseIcon
  275.  
  276.     // File Chooser Detail View code
  277.     private static class FileChooserDetailViewIcon implements Icon, UIResource, Serializable {
  278.         public void paintIcon(Component c, Graphics g, int x, int y) {
  279.         g.translate(x, y);
  280.  
  281.         // Draw outside edge of each of the documents
  282.         g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  283.         //     top
  284.         g.drawLine(2,2, 5,2); // top
  285.         g.drawLine(2,3, 2,7); // left
  286.         g.drawLine(3,7, 6,7); // bottom
  287.         g.drawLine(6,6, 6,3); // right
  288.         //     bottom
  289.         g.drawLine(2,10, 5,10); // top
  290.         g.drawLine(2,11, 2,15); // left
  291.         g.drawLine(3,15, 6,15); // bottom
  292.         g.drawLine(6,14, 6,11); // right
  293.  
  294.         // Draw little dots next to documents
  295.         //     Same color as outside edge
  296.         g.drawLine(8,5, 15,5);     // top
  297.         g.drawLine(8,13, 15,13);   // bottom
  298.  
  299.         // Draw inner highlight on documents
  300.         g.setColor(MetalLookAndFeel.getPrimaryControl());
  301.         g.drawRect(3,3, 2,3);   // top
  302.         g.drawRect(3,11, 2,3);  // bottom
  303.  
  304.         // Draw inner inner highlight on documents
  305.         g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  306.         g.drawLine(4,4, 4,5);     // top
  307.         g.drawLine(4,12, 4,13);   // bottom
  308.         
  309.         g.translate(-x, -y);
  310.     }
  311.     
  312.     public int getIconWidth() {
  313.         return 18;
  314.     }
  315.     
  316.     public int getIconHeight() {
  317.         return 18;
  318.     }
  319.     }  // End class FileChooserDetailViewIcon
  320.  
  321.     // File Chooser Home Folder code
  322.     private static class FileChooserHomeFolderIcon implements Icon, UIResource, Serializable {
  323.         public void paintIcon(Component c, Graphics g, int x, int y) {
  324.         g.translate(x, y);
  325.  
  326.         // Draw outside edge of house
  327.         g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  328.         g.drawLine(8,1, 1,8);  // left edge of roof
  329.         g.drawLine(8,1, 15,8); // right edge of roof
  330.         g.drawLine(11,2, 11,3); // left edge of chimney
  331.         g.drawLine(12,2, 12,4); // right edge of chimney
  332.         g.drawLine(3,7, 3,15); // left edge of house
  333.         g.drawLine(13,7, 13,15); // right edge of house
  334.         g.drawLine(4,15, 12,15); // bottom edge of house
  335.         // Draw door frame
  336.         //     same color as edge of house
  337.         g.drawLine( 6,9,  6,14); // left
  338.         g.drawLine(10,9, 10,14); // right
  339.         g.drawLine( 7,9,  9, 9); // top
  340.  
  341.         // Draw roof body
  342.             g.setColor(MetalLookAndFeel.getControlDarkShadow());
  343.         g.fillRect(8,2, 1,1); //top toward bottom
  344.         g.fillRect(7,3, 3,1);
  345.         g.fillRect(6,4, 5,1);
  346.         g.fillRect(5,5, 7,1);
  347.         g.fillRect(4,6, 9,2);
  348.         // Draw doornob
  349.         //     same color as roof body
  350.         g.drawLine(9,12, 9,12);
  351.  
  352.         // Paint the house
  353.         g.setColor(MetalLookAndFeel.getPrimaryControl());
  354.         g.drawLine(4,8, 12,8); // above door
  355.         g.fillRect(4,9, 2,6); // left of door
  356.         g.fillRect(11,9, 2,6); // right of door
  357.  
  358.         g.translate(-x, -y);
  359.     }
  360.     
  361.     public int getIconWidth() {
  362.         return 18;
  363.     }
  364.     
  365.     public int getIconHeight() {
  366.         return 18;
  367.     }
  368.     }  // End class FileChooserHomeFolderIcon
  369.  
  370.     // File Chooser List View code
  371.     private static class FileChooserListViewIcon implements Icon, UIResource, Serializable {
  372.         public void paintIcon(Component c, Graphics g, int x, int y) {
  373.         g.translate(x, y);
  374.  
  375.         // Draw outside edge of each of the documents
  376.         g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  377.         //     top left
  378.         g.drawLine(2,2, 5,2); // top
  379.         g.drawLine(2,3, 2,7); // left
  380.         g.drawLine(3,7, 6,7); // bottom
  381.         g.drawLine(6,6, 6,3); // right
  382.         //     top right
  383.         g.drawLine(10,2, 13,2); // top
  384.         g.drawLine(10,3, 10,7); // left
  385.         g.drawLine(11,7, 14,7); // bottom
  386.         g.drawLine(14,6, 14,3); // right
  387.         //     bottom left
  388.         g.drawLine(2,10, 5,10); // top
  389.         g.drawLine(2,11, 2,15); // left
  390.         g.drawLine(3,15, 6,15); // bottom
  391.         g.drawLine(6,14, 6,11); // right
  392.         //     bottom right
  393.         g.drawLine(10,10, 13,10); // top
  394.         g.drawLine(10,11, 10,15); // left
  395.         g.drawLine(11,15, 14,15); // bottom
  396.         g.drawLine(14,14, 14,11); // right
  397.  
  398.         // Draw little dots next to documents
  399.         //     Same color as outside edge
  400.         g.drawLine(8,5, 8,5);     // top left
  401.         g.drawLine(16,5, 16,5);   // top right
  402.         g.drawLine(8,13, 8,13);   // bottom left
  403.         g.drawLine(16,13, 16,13); // bottom right
  404.  
  405.         // Draw inner highlight on documents
  406.         g.setColor(MetalLookAndFeel.getPrimaryControl());
  407.         g.drawRect(3,3, 2,3);   // top left
  408.         g.drawRect(11,3, 2,3);  // top right
  409.         g.drawRect(3,11, 2,3);  // bottom left
  410.         g.drawRect(11,11, 2,3); // bottom right
  411.  
  412.         // Draw inner inner highlight on documents
  413.         g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  414.         g.drawLine(4,4, 4,5);     // top left
  415.         g.drawLine(12,4, 12,5);   // top right
  416.         g.drawLine(4,12, 4,13);   // bottom left
  417.         g.drawLine(12,12, 12,13); // bottom right
  418.         
  419.         g.translate(-x, -y);
  420.     }
  421.     
  422.     public int getIconWidth() {
  423.         return 18;
  424.     }
  425.     
  426.     public int getIconHeight() {
  427.         return 18;
  428.     }
  429.     }  // End class FileChooserListViewIcon
  430.  
  431.     // File Chooser New Folder code
  432.     private static class FileChooserNewFolderIcon implements Icon, UIResource, Serializable {
  433.         public void paintIcon(Component c, Graphics g, int x, int y) {
  434.         g.translate(x, y);
  435.  
  436.         // Fill background
  437.         g.setColor(MetalLookAndFeel.getPrimaryControl());
  438.         g.fillRect(3,5, 12,9);
  439.  
  440.         // Draw outside edge of folder
  441.         g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  442.         g.drawLine(1,6,    1,14); // left
  443.         g.drawLine(2,14,  15,14); // bottom
  444.         g.drawLine(15,13, 15,5);  // right
  445.         g.drawLine(2,5,    9,5);  // top left
  446.         g.drawLine(10,6,  14,6);  // top right
  447.  
  448.         // Draw inner folder highlight
  449.         g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  450.         g.drawLine( 2,6,  2,13); // left
  451.         g.drawLine( 3,6,  9,6);  // top left
  452.         g.drawLine(10,7, 14,7);  // top right
  453.  
  454.         // Draw tab on folder
  455.         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
  456.         g.drawLine(11,3, 15,3); // top
  457.         g.drawLine(10,4, 15,4); // bottom
  458.  
  459.         g.translate(-x, -y);
  460.     }
  461.     
  462.     public int getIconWidth() {
  463.         return 18;
  464.     }
  465.     
  466.     public int getIconHeight() {
  467.         return 18;
  468.     }
  469.     }  // End class FileChooserNewFolderIcon
  470.  
  471.     // File Chooser Up Folder code
  472.     private static class FileChooserUpFolderIcon implements Icon, UIResource, Serializable {
  473.         public void paintIcon(Component c, Graphics g, int x, int y) {
  474.         g.translate(x, y);
  475.  
  476.         // Fill background
  477.         g.setColor(MetalLookAndFeel.getPrimaryControl());
  478.         g.fillRect(3,5, 12,9);
  479.  
  480.         // Draw outside edge of folder
  481.         g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  482.         g.drawLine(1,6,    1,14); // left
  483.         g.drawLine(2,14,  15,14); // bottom
  484.         g.drawLine(15,13, 15,5);  // right
  485.         g.drawLine(2,5,    9,5);  // top left
  486.         g.drawLine(10,6,  14,6);  // top right
  487.         // Draw the UP arrow
  488.         //     same color as edge
  489.         g.drawLine(8,13,  8,16); // arrow shaft
  490.         g.drawLine(8, 9,  8, 9); // arrowhead top
  491.         g.drawLine(7,10,  9,10);
  492.         g.drawLine(6,11, 10,11);
  493.         g.drawLine(5,12, 11,12);
  494.  
  495.         // Draw inner folder highlight
  496.         g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  497.         g.drawLine( 2,6,  2,13); // left
  498.         g.drawLine( 3,6,  9,6);  // top left
  499.         g.drawLine(10,7, 14,7);  // top right
  500.  
  501.         // Draw tab on folder
  502.         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
  503.         g.drawLine(11,3, 15,3); // top
  504.         g.drawLine(10,4, 15,4); // bottom
  505.  
  506.         g.translate(-x, -y);
  507.     }
  508.     
  509.     public int getIconWidth() {
  510.         return 18;
  511.     }
  512.     
  513.     public int getIconHeight() {
  514.         return 18;
  515.     }
  516.     }  // End class FileChooserUpFolderIcon
  517.  
  518.     // Internal Frame Alternate Maximize code (actually, the un-maximize icon)
  519.     private static class InternalFrameAltMaximizeIcon implements Icon, UIResource, Serializable {
  520.     JButton parentButton;
  521.     ButtonModel buttonModel;
  522.     Color backgroundColor, titleColor, titleHighlight, edgeColor;
  523.     Color smallEdgeColor, downRightHighlight, upLeftHighlight;
  524.     int iconSize = 12;
  525.  
  526.         public InternalFrameAltMaximizeIcon(int size) {
  527.         iconSize = size;
  528.     }
  529.  
  530.         public void paintIcon(Component c, Graphics g, int x, int y) {
  531.         parentButton = (JButton)c;
  532.         buttonModel = parentButton.getModel();
  533.  
  534.         downRightHighlight = MetalLookAndFeel.getPrimaryControlHighlight();
  535.         upLeftHighlight = MetalLookAndFeel.getPrimaryControlShadow();
  536.         backgroundColor = MetalLookAndFeel.getPrimaryControl();
  537.         titleColor = MetalLookAndFeel.getPrimaryControlShadow();
  538.         titleHighlight = MetalLookAndFeel.getPrimaryControlDarkShadow();
  539.         edgeColor = MetalLookAndFeel.getPrimaryControlShadow();
  540.         smallEdgeColor = MetalLookAndFeel.getPrimaryControlInfo();
  541.  
  542.         if (parentButton.getClientProperty("paintActive")  != Boolean.TRUE) {
  543.         downRightHighlight = MetalLookAndFeel.getControlHighlight();
  544.         upLeftHighlight = MetalLookAndFeel.getControlShadow();
  545.         backgroundColor = MetalLookAndFeel.getControl();
  546.         titleColor = MetalLookAndFeel.getControlShadow();
  547.         titleHighlight = MetalLookAndFeel.getControlDarkShadow();
  548.         edgeColor = MetalLookAndFeel.getControlShadow();
  549.         }
  550.         else if (buttonModel.isPressed() && buttonModel.isArmed()) {
  551.         backgroundColor =  MetalLookAndFeel.getPrimaryControlShadow();
  552.         titleColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  553.         titleHighlight = MetalLookAndFeel.getPrimaryControlInfo();
  554.         edgeColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  555.         }
  556.  
  557.         // Some calculations that are needed more than once later on.
  558.         int oneThird = (int)(iconSize / 3);
  559.         int halfSize = (int)(iconSize / 2);
  560.  
  561.         g.translate(x, y);
  562.  
  563.         // fill background
  564.         g.setColor(backgroundColor);
  565.         g.fillRect(0,0, iconSize,iconSize);
  566.         
  567.         // draw downRight highlight
  568.         g.setColor(downRightHighlight);
  569.         g.drawLine(1,iconSize-1, iconSize-1,iconSize-1);
  570.         g.drawLine(iconSize-1,1, iconSize-1,iconSize-1);
  571.         
  572.         // draw upLeft highlight
  573.         g.setColor(upLeftHighlight);
  574.         g.drawLine(0,0, 0,iconSize-2);
  575.         g.drawLine(0,0, iconSize-2,0);
  576.  
  577.         // draw line around big edge of icon
  578.         g.setColor(edgeColor);
  579.         g.drawRect(1,1, iconSize-3,iconSize-3); // entire edge
  580.  
  581.         // draw line around small edge of window icon
  582.         g.setColor(smallEdgeColor);
  583.         g.drawRect(1,oneThird, halfSize,halfSize);
  584.  
  585.         // draw background color for title area
  586.         g.setColor(titleColor);
  587.         g.fillRect(2,oneThird+1, halfSize-1,halfSize-oneThird);
  588.  
  589.         // draw highlight for title area
  590.         g.setColor(titleHighlight);
  591.         g.drawLine(2,halfSize+1, oneThird,halfSize+1);
  592.         g.drawLine(oneThird+1,halfSize, halfSize,halfSize);
  593.  
  594.         g.translate(-x, -y);
  595.     }
  596.     
  597.     public int getIconWidth() {
  598.         return iconSize;
  599.     }
  600.     
  601.     public int getIconHeight() {
  602.         return iconSize;
  603.     }
  604.     }  // End class InternalFrameAltMaximizeIcon
  605.  
  606.     // Code for the default icons that goes in the upper left corner
  607.     private static class InternalFrameDefaultMenuIcon implements Icon, UIResource, Serializable {
  608.     Color backgroundColor, titleColor, edgeColor, slashColor;
  609.  
  610.         public void paintIcon(Component c, Graphics g, int x, int y) {
  611.         // still need to do the work for the inactive state
  612.  
  613.         backgroundColor = MetalLookAndFeel.getWindowBackground();
  614.         titleColor = MetalLookAndFeel.getPrimaryControl();
  615.         edgeColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  616.  
  617.         g.translate(x, y);
  618.  
  619.         // fill background
  620.         g.setColor(backgroundColor);
  621.         g.fillRect(0,0, 16,16);
  622.         
  623.         // draw background color for title area
  624.         g.setColor(titleColor);
  625.         g.fillRect(2,2, 12,2);
  626.         g.drawLine(2,4, 10,4);
  627.         g.drawLine(2,5,  9,5);
  628.  
  629.         // draw line around edge of title and icon
  630.         g.setColor(edgeColor);
  631.         g.drawRect(0,0, 15,15); // entire edge - pixel 1
  632.         g.drawRect(1,1, 13,13); // entire edge - pixel 2
  633.         g.drawLine( 2,6,  9,6);
  634.         g.drawLine(10,5, 10,5);
  635.         g.drawLine(11,4, 13,4);
  636.         //   draw dark part of two "bumps" (same color)
  637.         g.drawLine(4,4, 4,4);
  638.         g.drawLine(7,4, 7,4);
  639.  
  640.         //    draw light parts of two "bumps"
  641.         g.setColor(backgroundColor);
  642.         g.drawLine(3,3, 3,3);
  643.         g.drawLine(6,3, 6,3);
  644.  
  645.         g.translate(-x, -y);
  646.     }
  647.     
  648.     public int getIconWidth() {
  649.         return 16;
  650.     }
  651.     
  652.     public int getIconHeight() {
  653.         return 16;
  654.     }
  655.     }  // End class InternalFrameDefaultMenuIcon
  656.  
  657.     // Internal Frame Maximize code
  658.     private static class InternalFrameMaximizeIcon implements Icon, UIResource, Serializable {
  659.     protected JButton parentButton;
  660.     protected ButtonModel buttonModel;
  661.     protected Color backgroundColor, titleColor, titleHighlight, edgeColor;
  662.     protected Color downRightHighlight, upLeftHighlight;
  663.     protected int iconSize = 12;
  664.  
  665.         public InternalFrameMaximizeIcon(int size) {
  666.         iconSize = size;
  667.     }
  668.  
  669.         public void paintIcon(Component c, Graphics g, int x, int y) {
  670.         parentButton = (JButton)c;
  671.         buttonModel = parentButton.getModel();
  672.  
  673.         downRightHighlight = MetalLookAndFeel.getPrimaryControlHighlight();
  674.         upLeftHighlight = MetalLookAndFeel.getPrimaryControlShadow();
  675.         backgroundColor = MetalLookAndFeel.getPrimaryControl();
  676.         titleColor = MetalLookAndFeel.getPrimaryControlShadow();
  677.         titleHighlight = MetalLookAndFeel.getPrimaryControlDarkShadow();
  678.         edgeColor = MetalLookAndFeel.getPrimaryControlInfo();
  679.  
  680.         if (parentButton.getClientProperty("paintActive")  != Boolean.TRUE) {
  681.         downRightHighlight = MetalLookAndFeel.getControlHighlight();
  682.         upLeftHighlight = MetalLookAndFeel.getControlShadow();
  683.         backgroundColor = MetalLookAndFeel.getControl();
  684.         titleColor = MetalLookAndFeel.getControlShadow();
  685.         titleHighlight = MetalLookAndFeel.getControlDarkShadow();
  686.         }
  687.         else if (buttonModel.isPressed() && buttonModel.isArmed()) {
  688.         backgroundColor =  MetalLookAndFeel.getPrimaryControlShadow();
  689.         titleColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  690.         titleHighlight = MetalLookAndFeel.getPrimaryControlInfo();
  691.         }
  692.  
  693.         // Some calculations that are needed more than once later on.
  694.         int oneThird = (int)(iconSize / 3);
  695.         int twoThirds = (int)(iconSize * 2 / 3);
  696.         int halfSize = (int)(iconSize / 2);
  697.  
  698.         g.translate(x, y);
  699.  
  700.         // fill background
  701.         g.setColor(backgroundColor);
  702.         g.fillRect(0,0, iconSize,iconSize);
  703.         
  704.         // draw downRight highlight
  705.         g.setColor(downRightHighlight);
  706.         g.drawLine(1,iconSize-1, iconSize-1,iconSize-1);
  707.         g.drawLine(iconSize-1,1, iconSize-1,iconSize-1);
  708.         
  709.         // draw upLeft highlight
  710.         g.setColor(upLeftHighlight);
  711.         g.drawLine(0,0, 0,iconSize-2);
  712.         g.drawLine(0,0, iconSize-2,0);
  713.  
  714.         // draw background color for title area
  715.         g.setColor(titleColor);
  716.         g.fillRect(2,2, iconSize-3,oneThird-2);
  717.  
  718.         // draw line around edge of icon
  719.         g.setColor(edgeColor);
  720.         g.drawRect(1,1, iconSize-3,iconSize-3); // entire edge
  721.  
  722.         // draw highlight for title area
  723.         g.setColor(titleHighlight);
  724.         g.drawLine(2,oneThird, halfSize,oneThird);
  725.         g.drawLine(halfSize+1,oneThird-1, iconSize-3,oneThird-1);
  726.  
  727.         g.translate(-x, -y);
  728.     }
  729.     
  730.     public int getIconWidth() {
  731.         return iconSize;
  732.     }
  733.     
  734.     public int getIconHeight() {
  735.         return iconSize;
  736.     }
  737.     }  // End class InternalFrameMaximizeIcon
  738.  
  739.     // Internal Frame Minimize code
  740.     private static class InternalFrameMinimizeIcon implements Icon, UIResource, Serializable {
  741.     JButton parentButton;
  742.     ButtonModel buttonModel;
  743.     Color backgroundColor, titleColor, edgeColor, highlightColor;
  744.     Color downRightHighlight, upLeftHighlight;
  745.     int iconSize = 12;
  746.  
  747.         public InternalFrameMinimizeIcon(int size) {
  748.         iconSize = size;
  749.     }
  750.  
  751.         public void paintIcon(Component c, Graphics g, int x, int y) {
  752.         parentButton = (JButton)c;
  753.         buttonModel = parentButton.getModel();
  754.  
  755.         downRightHighlight = MetalLookAndFeel.getPrimaryControlHighlight();
  756.         upLeftHighlight = MetalLookAndFeel.getPrimaryControlShadow();
  757.         backgroundColor = MetalLookAndFeel.getPrimaryControl();
  758.         titleColor = MetalLookAndFeel.getPrimaryControlShadow();
  759.         edgeColor = MetalLookAndFeel.getPrimaryControlShadow();
  760.         highlightColor = MetalLookAndFeel.getPrimaryControlInfo();
  761.  
  762.         if (parentButton.getClientProperty("paintActive")  != Boolean.TRUE) {
  763.         downRightHighlight = MetalLookAndFeel.getControlHighlight();
  764.         upLeftHighlight = MetalLookAndFeel.getControlShadow();
  765.         backgroundColor = MetalLookAndFeel.getControl();
  766.         titleColor = MetalLookAndFeel.getControlShadow();
  767.         edgeColor = MetalLookAndFeel.getControlShadow();
  768.         }
  769.         else if (buttonModel.isPressed() && buttonModel.isArmed() ) {
  770.         backgroundColor =  MetalLookAndFeel.getPrimaryControlShadow();
  771.         titleColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  772.         edgeColor = MetalLookAndFeel.getPrimaryControlInfo();
  773.         }
  774.  
  775.         // Some calculations that are needed more than once later on.
  776.         int twoThirds = (int)(iconSize * 2 / 3);
  777.         int threeQuarters = (int)(iconSize * 3 / 4);
  778.  
  779.         g.translate(x, y);
  780.  
  781.         // fill background
  782.         g.setColor(backgroundColor);
  783.         g.fillRect(0,0, iconSize,iconSize);
  784.  
  785.         // draw downRight highlight
  786.         g.setColor(downRightHighlight);
  787.         g.drawLine(1,iconSize-1, iconSize-1,iconSize-1);
  788.         g.drawLine(iconSize-1,1, iconSize-1,iconSize-1);
  789.         
  790.         // draw upLeft highlight
  791.         g.setColor(upLeftHighlight);
  792.         g.drawLine(0,0, 0,iconSize-2);
  793.         g.drawLine(0,0, iconSize-2,0);
  794.  
  795.         // draw line around entire edge area
  796.         g.setColor(edgeColor);
  797.         g.drawRect(1,1, iconSize-3,iconSize-3);
  798.  
  799.         // draw background of title area
  800.         g.setColor(titleColor);
  801.         g.fillRect(1,twoThirds, iconSize-3,iconSize-twoThirds-2);
  802.  
  803.         // draw highlight for title area
  804.         g.setColor(highlightColor);
  805.         g.drawRect(1,twoThirds, iconSize-3,iconSize-twoThirds-2);
  806.  
  807.         g.translate(-x, -y);
  808.     }
  809.     
  810.     public int getIconWidth() {
  811.         return iconSize;
  812.     }
  813.     
  814.     public int getIconHeight() {
  815.         return iconSize;
  816.     }
  817.     }  // End class InternalFrameMinimizeIcon
  818.  
  819.     // Radio button code
  820.     private static class RadioButtonIcon implements Icon, UIResource, Serializable {
  821.     JRadioButton rb;
  822.     ButtonModel model;
  823.     boolean drawDot;
  824.     // only use on the RHS of equations
  825.     Color background, shadow;
  826.     // use in setColor();
  827.     Color darkCircle, dotColor, interiorColor;
  828.     Color whiteInnerLeftArc, whiteOuterRightArc;
  829.  
  830.         public void paintIcon(Component c, Graphics g, int x, int y) {
  831.         rb = (JRadioButton)c;
  832.         model = rb.getModel();
  833.         drawDot = model.isSelected();
  834.  
  835.         background = c.getBackground();
  836.         dotColor = c.getForeground();
  837.         shadow = MetalLookAndFeel.getControlShadow();
  838.         darkCircle = MetalLookAndFeel.getControlDarkShadow();
  839.         whiteInnerLeftArc = MetalLookAndFeel.getControlHighlight();
  840.         whiteOuterRightArc = MetalLookAndFeel.getControlHighlight();
  841.         interiorColor = background;
  842.  
  843.         // Set up colors per RadioButtonModel condition
  844.         if ( !model.isEnabled() ) {
  845.         whiteInnerLeftArc = whiteOuterRightArc = background;
  846.         darkCircle = dotColor = shadow;
  847.         }
  848.         else if (model.isPressed() && model.isArmed() ) {
  849.         whiteInnerLeftArc = interiorColor = shadow;
  850.         }
  851.         
  852.         g.translate(x, y);
  853.  
  854.         // fill interior
  855.         g.setColor(interiorColor);
  856.         g.fillRect(2,2, 9,9);
  857.        
  858.         // draw Dark Circle (start at top, go clockwise)
  859.         g.setColor(darkCircle);
  860.         g.drawLine( 4, 0,  7, 0);
  861.         g.drawLine( 8, 1,  9, 1);
  862.         g.drawLine(10, 2, 10, 3);
  863.         g.drawLine(11, 4, 11, 7);
  864.         g.drawLine(10, 8, 10, 9);
  865.         g.drawLine( 9,10,  8,10);
  866.         g.drawLine( 7,11,  4,11);
  867.         g.drawLine( 3,10,  2,10);
  868.         g.drawLine( 1, 9,  1, 8);
  869.         g.drawLine( 0, 7,  0, 4);
  870.         g.drawLine( 1, 3,  1, 2);
  871.         g.drawLine( 2, 1,  3, 1);
  872.  
  873.         // draw Inner Left (usually) White Arc
  874.         //  start at lower left corner, go clockwise
  875.         g.setColor(whiteInnerLeftArc);
  876.         g.drawLine( 2, 9,  2, 8);
  877.         g.drawLine( 1, 7,  1, 4);
  878.         g.drawLine( 2, 2,  2, 3);
  879.         g.drawLine( 2, 2,  3, 2);
  880.         g.drawLine( 4, 1,  7, 1);
  881.         g.drawLine( 8, 2,  9, 2);
  882.         // draw Outer Right White Arc
  883.         //  start at upper right corner, go clockwise
  884.         g.setColor(whiteOuterRightArc);
  885.         g.drawLine(10, 1, 10, 1);
  886.         g.drawLine(11, 2, 11, 3);
  887.         g.drawLine(12, 4, 12, 7);
  888.         g.drawLine(11, 8, 11, 9);
  889.         g.drawLine(10,10, 10,10);
  890.         g.drawLine( 9,11,  8,11);
  891.         g.drawLine( 7,12,  4,12);
  892.         g.drawLine( 3,11,  2,11);
  893.  
  894.         // selected dot
  895.         if ( drawDot ) {
  896.         g.setColor(dotColor);
  897.         g.fillRect( 4, 4,  4, 4);
  898.         g.drawLine( 4, 3,  7, 3);
  899.         g.drawLine( 8, 4,  8, 7);
  900.         g.drawLine( 7, 8,  4, 8);
  901.         g.drawLine( 3, 7,  3, 4);
  902.         }
  903.  
  904.         g.translate(-x, -y);
  905.     }
  906.     
  907.     public int getIconWidth() {
  908.         return 13;
  909.     }
  910.     
  911.     public int getIconHeight() {
  912.         return 13;
  913.     }
  914.     }  // End class RadioButtonIcon
  915.  
  916.     // Tree Computer Icon code
  917.     private static class TreeComputerIcon implements Icon, UIResource, Serializable {
  918.         public void paintIcon(Component c, Graphics g, int x, int y) {
  919.         g.translate(x, y);
  920.  
  921.         // Fill glass portion of monitor
  922.         g.setColor(MetalLookAndFeel.getPrimaryControl());
  923.         g.fillRect(5,4, 6,4);
  924.  
  925.         // Draw outside edge of monitor
  926.         g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  927.         g.drawLine( 2,2,  2,8); // left
  928.         g.drawLine(13,2, 13,8); // right
  929.         g.drawLine( 3,1, 12,1); // top
  930.         g.drawLine(12,9, 12,9); // bottom right base
  931.         g.drawLine( 3,9,  3,9); // bottom left base
  932.         // Draw the edge of the glass
  933.         g.drawLine( 4,4,  4,7); // left
  934.         g.drawLine( 5,3, 10,3); // top
  935.         g.drawLine(11,4, 11,7); // right
  936.         g.drawLine( 5,8, 10,8); // bottom
  937.         // Draw the edge of the CPU
  938.         g.drawLine( 1,10, 14,10); // top
  939.         g.drawLine(14,10, 14,14); // right
  940.         g.drawLine( 1,14, 14,14); // bottom
  941.         g.drawLine( 1,10,  1,14); // left
  942.  
  943.         // Draw the disk drives
  944.         g.setColor(MetalLookAndFeel.getControlDarkShadow());
  945.         g.drawLine( 6,12,  8,12); // left
  946.         g.drawLine(10,12, 12,12); // right
  947.  
  948.         g.translate(-x, -y);
  949.     }
  950.     
  951.     public int getIconWidth() {
  952.         return 16;
  953.     }
  954.     
  955.     public int getIconHeight() {
  956.         return 16;
  957.     }
  958.     }  // End class TreeComputerIcon
  959.  
  960.     // Tree HardDrive Icon code
  961.     private static class TreeHardDriveIcon implements Icon, UIResource, Serializable {
  962.         public void paintIcon(Component c, Graphics g, int x, int y) {
  963.         g.translate(x, y);
  964.  
  965.         // Draw edges of the disks
  966.         g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  967.         //     top disk
  968.         g.drawLine(1,4, 1,5); // left
  969.         g.drawLine(2,3, 3,3);
  970.         g.drawLine(4,2, 11,2); // top
  971.         g.drawLine(12,3, 13,3);
  972.         g.drawLine(14,4, 14,5); // right
  973.         g.drawLine(12,6, 13,6);
  974.         g.drawLine(4,7, 11,7); // bottom
  975.         g.drawLine(2,6, 3,6);
  976.         //     middle disk
  977.         g.drawLine(1,7, 1,8); // left
  978.         g.drawLine(2,9, 3,9);
  979.         g.drawLine(4,10, 11,10); // bottom
  980.         g.drawLine(12,9, 13,9);
  981.         g.drawLine(14,7, 14, 8); // right
  982.         //     bottom disk
  983.         g.drawLine(1,10, 1,11); // left
  984.         g.drawLine(2,12, 3,12);
  985.         g.drawLine(4,13, 11,13); // bottom
  986.         g.drawLine(12,12, 13,12);
  987.         g.drawLine(14,10, 14,11); // right
  988.  
  989.         // Draw the down right shadows
  990.         g.setColor(MetalLookAndFeel.getControlShadow());
  991.         //     top disk
  992.         g.drawLine(7,6, 7,6);
  993.         g.drawLine(9,6, 9,6);
  994.         g.drawLine(10,5, 10,5);
  995.         g.drawLine(11,6, 11,6);
  996.         g.drawLine(12,5, 13,5);
  997.         g.drawLine(13,4, 13,4);
  998.         //     middle disk
  999.         g.drawLine(7,9, 7,9);
  1000.         g.drawLine(9,9, 9,9);
  1001.         g.drawLine(10,8, 10,8);
  1002.         g.drawLine(11,9, 11,9);
  1003.         g.drawLine(12,8, 13,8);
  1004.         g.drawLine(13,7, 13,7);
  1005.         //     bottom disk
  1006.         g.drawLine(7,12, 7,12);
  1007.         g.drawLine(9,12, 9,12);
  1008.         g.drawLine(10,11, 10,11);
  1009.         g.drawLine(11,12, 11,12);
  1010.         g.drawLine(12,11, 13,11);
  1011.         g.drawLine(13,10, 13,10);
  1012.  
  1013.         // Draw the up left highlight
  1014.         g.setColor(MetalLookAndFeel.getControlHighlight());
  1015.         //     top disk
  1016.         g.drawLine(4,3, 5,3);
  1017.         g.drawLine(7,3, 9,3);
  1018.         g.drawLine(11,3, 11,3);
  1019.         g.drawLine(2,4, 6,4);
  1020.         g.drawLine(8,4, 8,4);
  1021.         g.drawLine(2,5, 3,5);
  1022.         g.drawLine(4,6, 4,6);
  1023.         //     middle disk
  1024.         g.drawLine(2,7, 3,7);
  1025.         g.drawLine(2,8, 3,8);
  1026.         g.drawLine(4,9, 4,9);
  1027.         //     bottom disk
  1028.         g.drawLine(2,10, 3,10);
  1029.         g.drawLine(2,11, 3,11);
  1030.         g.drawLine(4,12, 4,12);
  1031.  
  1032.         g.translate(-x, -y);
  1033.     }
  1034.     
  1035.     public int getIconWidth() {
  1036.         return 16;
  1037.     }
  1038.     
  1039.     public int getIconHeight() {
  1040.         return 16;
  1041.     }
  1042.     }  // End class TreeHardDriveIcon
  1043.  
  1044.     // Tree FloppyDrive Icon code
  1045.     private static class TreeFloppyDriveIcon implements Icon, UIResource, Serializable {
  1046.         public void paintIcon(Component c, Graphics g, int x, int y) {
  1047.         g.translate(x, y);
  1048.  
  1049.         // Fill body of floppy
  1050.         g.setColor(MetalLookAndFeel.getPrimaryControl());
  1051.         g.fillRect(2,2, 12,12);
  1052.  
  1053.         // Draw outside edge of floppy
  1054.         g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  1055.         g.drawLine( 1, 1, 13, 1); // top
  1056.         g.drawLine(14, 2, 14,14); // right
  1057.         g.drawLine( 1,14, 14,14); // bottom
  1058.         g.drawLine( 1, 1,  1,14); // left
  1059.  
  1060.         // Draw grey-ish highlights
  1061.         g.setColor(MetalLookAndFeel.getControlDarkShadow());
  1062.         g.fillRect(5,2, 6,5); // metal disk protector part
  1063.         g.drawLine(4,8, 11,8); // top of label
  1064.         g.drawLine(3,9, 3,13); // left of label
  1065.         g.drawLine(12,9, 12,13); // right of label
  1066.  
  1067.         // Draw label and exposed disk
  1068.         g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  1069.         g.fillRect(8,3, 2,3); // exposed disk
  1070.         g.fillRect(4,9, 8,5); // label
  1071.  
  1072.         // Draw text on label
  1073.         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
  1074.         g.drawLine(5,10, 9,10);
  1075.         g.drawLine(5,12, 8,12);
  1076.  
  1077.         g.translate(-x, -y);
  1078.     }
  1079.     
  1080.     public int getIconWidth() {
  1081.         return 16;
  1082.     }
  1083.     
  1084.     public int getIconHeight() {
  1085.         return 16;
  1086.     }
  1087.     }  // End class TreeFloppyDriveIcon
  1088.  
  1089.  
  1090.     static private final Dimension folderIcon16Size = new Dimension( 16, 16 );
  1091.  
  1092.     /**
  1093.      * <p>
  1094.      * Warning: serialized objects of this class will not be compatible with
  1095.      * future swing releases.  The current serialization support is appropriate
  1096.      * for short term storage or RMI between Swing1.0 applications.  It will
  1097.      * not be possible to load serialized Swing1.0 objects with future releases
  1098.      * of Swing.  The JDK1.2 release of Swing will be the compatibility
  1099.      * baseline for the serialized form of Swing objects.
  1100.      */
  1101.     public static class FolderIcon16 implements Icon, Serializable {
  1102.     public void paintIcon(Component c, Graphics g, int x, int y) {
  1103.         g.translate( x, y + getShift() );
  1104.  
  1105.         int right = folderIcon16Size.width - 1;
  1106.         int bottom = folderIcon16Size.height - 1;
  1107.  
  1108.         // Draw tab top
  1109.         g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
  1110.         g.drawLine( right - 5, 3, right, 3 );
  1111.         g.drawLine( right - 6, 4, right, 4 );
  1112.  
  1113.         // Draw folder front
  1114.         g.setColor( MetalLookAndFeel.getPrimaryControl() );
  1115.         g.fillRect( 2, 7, 13, 8 );
  1116.  
  1117.         // Draw tab bottom
  1118.         g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );
  1119.         g.drawLine( right - 6, 5, right - 1, 5 );
  1120.  
  1121.         // Draw outline
  1122.         g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
  1123.         g.drawLine( 0, 6, 0, bottom );            // left side
  1124.         g.drawLine( 1, 5, right - 7, 5 );         // first part of top
  1125.         g.drawLine( right - 6, 6, right - 1, 6 ); // second part of top
  1126.         g.drawLine( right, 5, right, bottom );    // right side
  1127.         g.drawLine( 0, bottom, right, bottom );   // bottom
  1128.  
  1129.         // Draw highlight
  1130.         g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
  1131.         g.drawLine( 1, 6, 1, bottom - 1 );
  1132.         g.drawLine( 1, 6, right - 7, 6 );
  1133.         g.drawLine( right - 6, 7, right - 1, 7 );
  1134.  
  1135.         g.translate( -x, -(y + getShift()) );
  1136.     }
  1137.  
  1138.         public int getShift() { return 0; }
  1139.         public int getAdditionalHeight() { return 0; }
  1140.  
  1141.     public int getIconWidth() { return folderIcon16Size.width; }
  1142.     public int getIconHeight() { return folderIcon16Size.height + getAdditionalHeight(); }
  1143.     }
  1144.  
  1145.   
  1146.     /**
  1147.      * <p>
  1148.      * Warning: serialized objects of this class will not be compatible with
  1149.      * future swing releases.  The current serialization support is appropriate
  1150.      * for short term storage or RMI between Swing1.0 applications.  It will
  1151.      * not be possible to load serialized Swing1.0 objects with future releases
  1152.      * of Swing.  The JDK1.2 release of Swing will be the compatibility
  1153.      * baseline for the serialized form of Swing objects.
  1154.      */
  1155.     public static class TreeFolderIcon extends FolderIcon16 {
  1156.         public int getShift() { return -1; }
  1157.         public int getAdditionalHeight() { return 2; }
  1158.     }
  1159.  
  1160.  
  1161.     static private final Dimension fileIcon16Size = new Dimension( 16, 16 );
  1162.  
  1163.     /**
  1164.      * <p>
  1165.      * Warning: serialized objects of this class will not be compatible with
  1166.      * future swing releases.  The current serialization support is appropriate
  1167.      * for short term storage or RMI between Swing1.0 applications.  It will
  1168.      * not be possible to load serialized Swing1.0 objects with future releases
  1169.      * of Swing.  The JDK1.2 release of Swing will be the compatibility
  1170.      * baseline for the serialized form of Swing objects.
  1171.      */
  1172.     public static class FileIcon16 implements Icon, Serializable {
  1173.     public void paintIcon(Component c, Graphics g, int x, int y) {
  1174.         g.translate( x, y + getShift() );
  1175.  
  1176.         int right = fileIcon16Size.width - 1;
  1177.         int bottom = fileIcon16Size.height - 1;
  1178.  
  1179.         // Draw fill
  1180.         g.setColor( MetalLookAndFeel.getWindowBackground() );
  1181.         g.fillRect( 4, 2, 9, 12 );
  1182.  
  1183.         // Draw frame
  1184.         g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
  1185.         g.drawLine( 2, 0, 2, bottom );                 // left
  1186.         g.drawLine( 2, 0, right - 4, 0 );              // top
  1187.         g.drawLine( 2, bottom, right - 1, bottom );    // bottom
  1188.         g.drawLine( right - 1, 6, right - 1, bottom ); // right
  1189.         g.drawLine( right - 6, 2, right - 2, 6 );      // slant 1
  1190.         g.drawLine( right - 5, 1, right - 4, 1 );      // part of slant 2
  1191.         g.drawLine( right - 3, 2, right - 3, 3 );      // part of slant 2
  1192.         g.drawLine( right - 2, 4, right - 2, 5 );      // part of slant 2
  1193.  
  1194.         // Draw highlight
  1195.         g.setColor( MetalLookAndFeel.getPrimaryControl() );
  1196.         g.drawLine( 3, 1, 3, bottom - 1 );                  // left
  1197.         g.drawLine( 3, 1, right - 6, 1 );                   // top
  1198.         g.drawLine( right - 2, 7, right - 2, bottom - 1 );  // right
  1199.         g.drawLine( right - 5, 2, right - 3, 4 );           // slant
  1200.         g.drawLine( 3, bottom - 1, right - 2, bottom - 1 ); // bottom
  1201.  
  1202.         g.translate( -x, -(y + getShift()) );
  1203.     }
  1204.  
  1205.         public int getShift() { return 0; }
  1206.         public int getAdditionalHeight() { return 0; }
  1207.  
  1208.     public int getIconWidth() { return fileIcon16Size.width; }
  1209.     public int getIconHeight() { return fileIcon16Size.height + getAdditionalHeight(); }
  1210.     }
  1211.  
  1212.  
  1213.     public static class TreeLeafIcon extends FileIcon16 {
  1214.         public int getShift() { return 2; }
  1215.         public int getAdditionalHeight() { return 4; }
  1216.     }
  1217.  
  1218.  
  1219.     static private final Dimension treeControlSize = new Dimension( 8, 8 );
  1220.  
  1221.     /**
  1222.      * <p>
  1223.      * Warning: serialized objects of this class will not be compatible with
  1224.      * future swing releases.  The current serialization support is appropriate
  1225.      * for short term storage or RMI between Swing1.0 applications.  It will
  1226.      * not be possible to load serialized Swing1.0 objects with future releases
  1227.      * of Swing.  The JDK1.2 release of Swing will be the compatibility
  1228.      * baseline for the serialized form of Swing objects.
  1229.      */
  1230.     public static class TreeControlIcon implements Icon, Serializable {
  1231.         protected boolean isLight;
  1232.  
  1233.         public TreeControlIcon( boolean isLight ) {
  1234.         this.isLight = isLight;
  1235.     }
  1236.  
  1237.     public void paintIcon(Component c, Graphics g, int x, int y) {
  1238.         g.translate( x, y );
  1239.  
  1240.         // Draw background
  1241.         g.setColor( isLight ? MetalLookAndFeel.getPrimaryControl() :
  1242.                       MetalLookAndFeel.getPrimaryControlDarkShadow() );
  1243.         g.fillRect( 1, 1, 6, 6 );
  1244.  
  1245.         // Draw circle
  1246.         g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
  1247.         g.drawLine( 0, 2, 0, 5 );     // left
  1248.         g.drawLine( 1, 1, 1, 1 );     // top left dot
  1249.         g.drawLine( 2, 0, 5, 0 );     // top
  1250.         g.drawLine( 6, 1, 6, 1 );     // top right dot
  1251.         g.drawLine( 7, 2, 7, 5 );     // right
  1252.         g.drawLine( 6, 6, 6, 6 );     // botom right dot
  1253.         g.drawLine( 2, 7, 5, 7 );     // bottom
  1254.         g.drawLine( 1, 6, 1, 6 );     // bottom left dot
  1255.  
  1256.         // Draw highlight
  1257.         g.setColor( isLight ? MetalLookAndFeel.getPrimaryControlHighlight() :
  1258.                       MetalLookAndFeel.getPrimaryControlShadow() );
  1259.         g.drawLine( 1, 2, 1, 5 );     // left
  1260.         g.drawLine( 2, 1, 5, 1 );     // top
  1261.  
  1262.         g.translate( -x, -y );
  1263.     }
  1264.  
  1265.     public int getIconWidth() { return treeControlSize.width; }
  1266.     public int getIconHeight() { return treeControlSize.height; }
  1267.     }
  1268.  
  1269.   //
  1270.   // Menu Icons
  1271.   //
  1272.  
  1273.     static private final Dimension menuArrowIconSize = new Dimension( 4, 8 );
  1274.     static private final Dimension menuCheckIconSize = new Dimension( 12, 10 );
  1275.     static private final int xOff = 4;
  1276.  
  1277.     private static class MenuArrowIcon implements Icon, UIResource, Serializable
  1278.     {
  1279.     public void paintIcon( Component c, Graphics g, int x, int y )
  1280.     {
  1281.         JMenuItem b = (JMenuItem) c;
  1282.         ButtonModel model = b.getModel();
  1283.  
  1284.         g.translate( x, y );
  1285.  
  1286.         if ( !model.isEnabled() )
  1287.         {
  1288.             g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
  1289.         }
  1290.         else
  1291.         {
  1292.             if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
  1293.         {
  1294.             g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
  1295.         }
  1296.         else
  1297.         {
  1298.             g.setColor( b.getForeground() );
  1299.         }
  1300.         }
  1301.  
  1302.         g.drawLine( 0, 0, 0, 7 );
  1303.         g.drawLine( 1, 1, 1, 6 );
  1304.         g.drawLine( 2, 2, 2, 5 );
  1305.         g.drawLine( 3, 3, 3, 4 );
  1306.  
  1307.         g.translate( -x, -y );
  1308.     }
  1309.  
  1310.     public int getIconWidth() { return menuArrowIconSize.width; }
  1311.  
  1312.     public int getIconHeight() { return menuArrowIconSize.height; }
  1313.  
  1314.     } // End class MenuArrowIcon
  1315.  
  1316.     private static class MenuItemCheckIcon implements Icon, UIResource, Serializable
  1317.     {
  1318.     public void paintIcon( Component c, Graphics g, int x, int y )
  1319.     {
  1320.     }
  1321.  
  1322.     public int getIconWidth() { return menuCheckIconSize.width; }
  1323.  
  1324.     public int getIconHeight() { return menuCheckIconSize.height; }
  1325.  
  1326.     } // End class MenuItemCheckIcon
  1327.  
  1328.     private static class MenuItemArrowIcon implements Icon, UIResource, Serializable
  1329.     {
  1330.     public void paintIcon( Component c, Graphics g, int x, int y )
  1331.     {
  1332.     }
  1333.  
  1334.     public int getIconWidth() { return menuArrowIconSize.width; }
  1335.  
  1336.     public int getIconHeight() { return menuArrowIconSize.height; }
  1337.  
  1338.     } // End class MenuItemArrowIcon
  1339.  
  1340.     private static class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable
  1341.     {
  1342.     public void paintIcon( Component c, Graphics g, int x, int y )
  1343.     {
  1344.         JMenuItem b = (JMenuItem) c;
  1345.         ButtonModel model = b.getModel();
  1346.  
  1347.         boolean isSelected = model.isSelected();
  1348.         boolean isEnabled = model.isEnabled();
  1349.         boolean isPressed = model.isPressed();
  1350.         boolean isArmed = model.isArmed();
  1351.         
  1352.         g.translate( x + xOff, y );
  1353.  
  1354.         if ( isEnabled )
  1355.         {
  1356.             if ( isPressed || isArmed )
  1357.         {
  1358.             g.setColor( MetalLookAndFeel.getControlInfo()  );
  1359.             g.drawLine( 0, 0, 8, 0 );
  1360.             g.drawLine( 0, 0, 0, 8 );
  1361.             g.drawLine( 8, 2, 8, 8 );
  1362.             g.drawLine( 2, 8, 8, 8 );
  1363.  
  1364.             g.setColor( MetalLookAndFeel.getPrimaryControl()  );
  1365.             g.drawLine( 1, 1, 7, 1 );
  1366.             g.drawLine( 1, 1, 1, 7 );
  1367.             g.drawLine( 9, 1, 9, 9 );
  1368.             g.drawLine( 1, 9, 9, 9 );
  1369.         }
  1370.         else
  1371.         {
  1372.             g.setColor( MetalLookAndFeel.getControlDarkShadow()  );
  1373.             g.drawLine( 0, 0, 8, 0 );
  1374.             g.drawLine( 0, 0, 0, 8 );
  1375.             g.drawLine( 8, 2, 8, 8 );
  1376.             g.drawLine( 2, 8, 8, 8 );
  1377.  
  1378.             g.setColor( MetalLookAndFeel.getControlHighlight()  );
  1379.             g.drawLine( 1, 1, 7, 1 );
  1380.             g.drawLine( 1, 1, 1, 7 );
  1381.             g.drawLine( 9, 1, 9, 9 );
  1382.             g.drawLine( 1, 9, 9, 9 );
  1383.         }
  1384.         }
  1385.         else
  1386.         {
  1387.             g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
  1388.         g.drawRect( 0, 0, 8, 8 );
  1389.         }
  1390.  
  1391.         if ( isSelected )
  1392.         {
  1393.             if ( isEnabled )
  1394.         {
  1395.             if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
  1396.             {
  1397.                 g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
  1398.             }
  1399.             else
  1400.             {
  1401.                 g.setColor( b.getForeground() );
  1402.             }
  1403.         }
  1404.         else
  1405.         {
  1406.             g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
  1407.         }
  1408.  
  1409.         g.drawLine( 2, 2, 2, 6 );
  1410.         g.drawLine( 3, 2, 3, 6 );
  1411.         g.drawLine( 4, 4, 8, 0 );
  1412.         g.drawLine( 4, 5, 9, 0 );
  1413.         }
  1414.  
  1415.         g.translate( -(x + xOff), -y );
  1416.     }
  1417.  
  1418.     public int getIconWidth() { return menuCheckIconSize.width; }
  1419.  
  1420.     public int getIconHeight() { return menuCheckIconSize.height; }
  1421.  
  1422.     }  // End class CheckBoxMenuItemIcon
  1423.  
  1424.     private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable
  1425.     {
  1426.     public void paintIcon( Component c, Graphics g, int x, int y )
  1427.     {
  1428.         JMenuItem b = (JMenuItem) c;
  1429.         ButtonModel model = b.getModel();
  1430.  
  1431.         boolean isSelected = model.isSelected();
  1432.         boolean isEnabled = model.isEnabled();
  1433.         boolean isPressed = model.isPressed();
  1434.         boolean isArmed = model.isArmed();
  1435.         
  1436.         g.translate( x + xOff, y );
  1437.  
  1438.         if ( isEnabled )
  1439.         {
  1440.             if ( isPressed || isArmed )
  1441.         {
  1442.             g.setColor( MetalLookAndFeel.getPrimaryControl()  );
  1443.             g.drawLine( 3, 1, 8, 1 );
  1444.             g.drawLine( 2, 9, 7, 9 );
  1445.             g.drawLine( 1, 3, 1, 8 );
  1446.             g.drawLine( 9, 2, 9, 7 );
  1447.             g.drawLine( 2, 2, 2, 2 );
  1448.             g.drawLine( 8, 8, 8, 8 );
  1449.  
  1450.             g.setColor( MetalLookAndFeel.getControlInfo()  );
  1451.             g.drawLine( 2, 0, 6, 0 );
  1452.             g.drawLine( 2, 8, 6, 8 );
  1453.             g.drawLine( 0, 2, 0, 6 );
  1454.             g.drawLine( 8, 2, 8, 6 );
  1455.             g.drawLine( 1, 1, 1, 1 );
  1456.             g.drawLine( 7, 1, 7, 1 );
  1457.             g.drawLine( 1, 7, 1, 7 );
  1458.             g.drawLine( 7, 7, 7, 7 );
  1459.         }
  1460.         else
  1461.         {
  1462.             g.setColor( MetalLookAndFeel.getControlHighlight()  );
  1463.             g.drawLine( 3, 1, 8, 1 );
  1464.             g.drawLine( 2, 9, 7, 9 );
  1465.             g.drawLine( 1, 3, 1, 8 );
  1466.             g.drawLine( 9, 2, 9, 7 );
  1467.             g.drawLine( 2, 2, 2, 2 );
  1468.             g.drawLine( 8, 8, 8, 8 );
  1469.  
  1470.             g.setColor( MetalLookAndFeel.getControlDarkShadow()  );
  1471.             g.drawLine( 2, 0, 6, 0 );
  1472.             g.drawLine( 2, 8, 6, 8 );
  1473.             g.drawLine( 0, 2, 0, 6 );
  1474.             g.drawLine( 8, 2, 8, 6 );
  1475.             g.drawLine( 1, 1, 1, 1 );
  1476.             g.drawLine( 7, 1, 7, 1 );
  1477.             g.drawLine( 1, 7, 1, 7 );
  1478.             g.drawLine( 7, 7, 7, 7 );
  1479.         }
  1480.         }
  1481.         else
  1482.         {
  1483.             g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
  1484.         g.drawLine( 2, 0, 6, 0 );
  1485.         g.drawLine( 2, 8, 6, 8 );
  1486.         g.drawLine( 0, 2, 0, 6 );
  1487.         g.drawLine( 8, 2, 8, 6 );
  1488.         g.drawLine( 1, 1, 1, 1 );
  1489.         g.drawLine( 7, 1, 7, 1 );
  1490.         g.drawLine( 1, 7, 1, 7 );
  1491.         g.drawLine( 7, 7, 7, 7 );
  1492.         }
  1493.  
  1494.         if ( isSelected )
  1495.         {
  1496.             if ( isEnabled )
  1497.         {
  1498.             if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
  1499.             {
  1500.                 g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
  1501.             }
  1502.             else
  1503.             {
  1504.                 g.setColor( b.getForeground() );
  1505.             }
  1506.         }
  1507.         else
  1508.         {
  1509.             g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
  1510.         }
  1511.  
  1512.         g.drawLine( 3, 2, 5, 2 );
  1513.         g.drawLine( 2, 3, 6, 3 );
  1514.         g.drawLine( 2, 4, 6, 4 );
  1515.         g.drawLine( 2, 5, 6, 5 );
  1516.         g.drawLine( 3, 6, 5, 6 );
  1517.         }
  1518.  
  1519.         g.translate( -(x + xOff), -y );
  1520.     }
  1521.  
  1522.     public int getIconWidth() { return menuCheckIconSize.width; }
  1523.  
  1524.     public int getIconHeight() { return menuCheckIconSize.height; }
  1525.  
  1526.     }  // End class RadioButtonMenuItemIcon
  1527.  
  1528. private static class VerticalSliderThumbIcon implements Icon, Serializable, UIResource {
  1529.     protected static MetalBumps bumps;
  1530.  
  1531.     public VerticalSliderThumbIcon() {
  1532.         bumps = new MetalBumps( 6, 10,
  1533.                 MetalLookAndFeel.getPrimaryControl(),
  1534.                 MetalLookAndFeel.getPrimaryControlDarkShadow(),
  1535.                 MetalLookAndFeel.getPrimaryControlShadow() );   
  1536.     } 
  1537.  
  1538.     public void paintIcon( Component c, Graphics g, int x, int y ) {
  1539.         JSlider slider = (JSlider)c;
  1540.  
  1541.         g.translate( x, y );
  1542.  
  1543.     // Draw the frame
  1544.     g.setColor( slider.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
  1545.                                  MetalLookAndFeel.getControlDarkShadow() );
  1546.     g.drawLine(  1,0  ,  8,0 );  // top
  1547.     g.drawLine(  0,1  ,  0,13 ); // left
  1548.     g.drawLine(  1,14 ,  8,14 ); // bottom
  1549.     g.drawLine(  9,1  , 15,7  ); // top slant
  1550.     g.drawLine(  9,13 , 15,7  ); // bottom slant
  1551.  
  1552.     // Fill in the background
  1553.     g.setColor( slider.isEnabled() ? c.getForeground() : MetalLookAndFeel.getControlShadow() );
  1554.     g.fillRect( 1,1, 8, 13 );
  1555.  
  1556.     g.drawLine(  9,2 ,  9,12 );
  1557.     g.drawLine( 10,3 , 10,11 );
  1558.     g.drawLine( 11,4 , 11,10 );
  1559.     g.drawLine( 12,5 , 12,9 );
  1560.     g.drawLine( 13,6 , 13,8 );
  1561.     g.drawLine( 14,7 , 14,7 );
  1562.  
  1563.     // Draw the bumps
  1564.     if ( slider.isEnabled() ) {
  1565.         bumps.paintIcon( c, g, 3, 3 );
  1566.     }
  1567.  
  1568.         g.translate( -x, -y );
  1569.     }
  1570.  
  1571.     public int getIconWidth() {
  1572.         return 16;
  1573.     }
  1574.  
  1575.     public int getIconHeight() {
  1576.         return 15;
  1577.     }
  1578. }
  1579.  
  1580. private static class HorizontalSliderThumbIcon implements Icon, Serializable, UIResource {
  1581.     protected static MetalBumps bumps;
  1582.  
  1583.     public HorizontalSliderThumbIcon() {
  1584.         bumps = new MetalBumps( 10, 6,
  1585.                 MetalLookAndFeel.getPrimaryControl(),
  1586.                 MetalLookAndFeel.getPrimaryControlDarkShadow(),
  1587.                 MetalLookAndFeel.getPrimaryControlShadow() );        
  1588.     }
  1589.  
  1590.     public void paintIcon( Component c, Graphics g, int x, int y ) {
  1591.         JSlider slider = (JSlider)c;
  1592.  
  1593.         g.translate( x, y );
  1594.     
  1595.     // Draw the frame
  1596.     g.setColor( slider.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
  1597.                                  MetalLookAndFeel.getControlDarkShadow() );
  1598.     g.drawLine(  1,0  , 13,0 );  // top
  1599.     g.drawLine(  0,1  ,  0,8 );  // left
  1600.     g.drawLine( 14,1  , 14,8 );  // right
  1601.     g.drawLine(  1,9  ,  7,15 ); // left slant
  1602.     g.drawLine(  7,15 , 14,8 );  // right slant
  1603.  
  1604.     // Fill in the background
  1605.     g.setColor( slider.isEnabled() ? c.getForeground() : MetalLookAndFeel.getControlShadow() );
  1606.     g.fillRect( 1,1, 13, 8 );
  1607.  
  1608.     g.drawLine( 2,9  , 12,9 );
  1609.     g.drawLine( 3,10 , 11,10 );
  1610.     g.drawLine( 4,11 , 10,11 );
  1611.     g.drawLine( 5,12 ,  9,12 );
  1612.     g.drawLine( 6,13 ,  8,13 );
  1613.     g.drawLine( 7,14 ,  7,14 );
  1614.  
  1615.     // Draw the bumps
  1616.     if ( slider.isEnabled() ) {
  1617.         bumps.paintIcon( c, g, 3, 3 );
  1618.     }
  1619.  
  1620.         g.translate( -x, -y );
  1621.     }
  1622.  
  1623.     public int getIconWidth() {
  1624.         return 15;
  1625.     }
  1626.  
  1627.     public int getIconHeight() {
  1628.         return 16;
  1629.     }
  1630. }
  1631.  
  1632. }
  1633.